package com.rong.structural.compositeModel;

import java.util.ArrayList;
import java.util.List;

// 就是Composite 可以管理College
public class University extends OrganizationComponent {
    List<OrganizationComponent> list = new ArrayList<>();

    public University(String name, String des) {
        super(name, des);
    }

    // 输出包含的学院
    @Override
    protected void print() {
        System.out.println("------" + this.getName() + "------");
        // 遍历list
        for (OrganizationComponent organizationComponent : list){
            organizationComponent.print();
        }
    }

    // 重写add方法
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        list.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        list.remove(organizationComponent);
    }

    @Override
    public String getName() {
        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }
}
